// 垃圾桶动态效果
var trashcanSwitch = function (mode) {
  var trashcanLid = document.getElementById("trashcan-lid").style;
  var trashcanBody = document.getElementById("trashcan-body").style;
  var trashCan = document.getElementById("trashcan").style;

  if (mode) {
    trashcanLid.zIndex = 7;
    trashcanBody.zIndex = 7;
    trashCan.zIndex = 6;
    trashcanLid.opacity = 1;
    trashcanBody.opacity = 1;
    trashCan.opacity = 1;

    // 获取指针x坐标
    function mouse_X() {
      var posX = 0;
      var event = event || window.event;
      if (!event) {
        return undefined;
      }
      if (event.pageX) {
        posX = event.pageX;
      } else if (event.clientX) {
        posX = event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
      }
      return posX;
    }

    var mou_X = mouse_X() || mou_X;
    if (mou_X < 60) {
      trashCover(true);
    } else {
      trashCover(false);
    }
  } else {
    trashcanLid.opacity = 0;
    trashcanBody.opacity = 0;
    trashCan.opacity = 0;
    try {
      trashcanLid.zIndex = 0;
      trashcanBody.zIndex = 0;
      trashCan.zIndex = 0;
    } catch (error) {
      //pass
    }
  }
};

var trashCover = function (mode) {
  // 垃圾桶开盖
  var trashcanLid = document.getElementById("trashcan-lid").style;
  if (mode) {
    trashcanLid.transform = "translate(-4px,-4px) rotate(-20deg)";
  } else {
    trashcanLid.transform = "translate(0px) rotate(0deg)";
  }
};
